package edu.nf.ch05.controller;

import edu.nf.ch05.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * @author wangl
 * @date 2025/4/28
 */
//@Component
//从3.0开始控制层使用@Controller的注解标识
@Controller
public class UserController {

    /**
     * spring官方提供的注入注解@Autowired
     * 可以标注在字段、构造方法、set方法上进行注入
     */
    //@Autowired
    private UserService userService;

    private String host;

    public void setHost(String host) {
        this.host = host;
    }

    //构造方法注入
    //从4.3开始，构造方法注入不需要任何注解
    //@Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    //set方法注入
    /*@Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }*/

    public void save() {
        userService.save();
    }
}